package practice;

import java.util.Scanner;

public class Pra_ {
	public void test01() {
		for (int i = 1; i <= 9; i++) {
			for (int j = 1; j <= i; j++)
				System.out.print(j + " × " + i + " = " + i * j + "    \t");
			System.out.println();
		}
	}
	
	public void test02() {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);
		System.out.print("请输入两个整数：");
		int m = scan.nextInt();
		int n = scan.nextInt();
		int a = m, b = n, r;
		if (m < n) {
			r = m;
			m = n;
			n = r;
		}
		while ((r = m % n) != 0) {
			m = n;
			n = r;
		}
		System.out.println("最小公约数：" + n);
		System.out.println("最大公倍数：" + a * b / n);
	}
	
	public void test03() {
		int n = 24;
		int[] sum = new int[n];
		sum[0] = sum[1] = 2;
		for (int i = 2; i < n; i++)
			sum[i] = sum[i - 2] + sum[i - 1];
		for (int i = 0; i < n; i++)
			System.out.println("第" + (i + 1) + "个月兔子总数：" + sum[i] + "只");
	}

	public void test04() {
		int num = 0;
		System.out.println("101到200之间的素数：");
		for (int n = 101; n <= 200; n++) {
			boolean tf = true;
			for (int i = 2; i <= Math.sqrt(n); i++)
				if (n % i == 0) {
					tf = false;
					break;
				}
			if (tf) {
				System.out.println(n);
				num++;
			}
		}
		System.out.println("总计：" + num + "个");
	}

	public void test05() {
		int[] a = new int[3];
		System.out.println("水仙花数：");
		for (int i = 100, n; i < 1000; i++) {
			n = i;
			for (int j = 0; j < 3; j++) {
				a[j] = n % 10;
				n /= 10;
			}
			if (Math.pow(a[0], 3) + Math.pow(a[1], 3) + Math.pow(a[2], 3) == i)
				System.out.println(i);
		}
	}
}
